package com.shadow.shiro.filter;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * XSS过滤.
 * @author Pbody
 * @create: 2019-03-30 16:49
 */
@Slf4j
public class XssFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) {
        log.debug("XssFilter init...");
    }

    /**
     * XSS过滤处理.
     * @author Pbody
     * @date 11:16 2020/9/25
     * @param request 请求
     * @param response 相应
     * @param chain 过滤chain
     **/
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {
        log.debug("XssFilter doFilter...");
        XssRequestWrapper xssRequest = new XssRequestWrapper((HttpServletRequest) request);
        chain.doFilter(xssRequest, response);
    }

    @Override
    public void destroy() {
        log.debug("XssFilter destroy...");
    }


}
